package org.bugeden.netdisk.common

import collection.mutable.ListBuffer

/**
 * Created by IntelliJ IDEA.
 * User: inotseeyou
 * Date: 2010-11-12
 * Time: 0:28:00
 * To change this template use File | Settings | File Templates.
 */

object Lang {
  def splitArray[T](array: Array[T], n: Int): List[Array[T]] = {
    val list = new ListBuffer[Array[T]]()
    val (first, tail) = array.splitAt(n)
    list.append(first)
    if (!tail.isEmpty) {
      val tailList = this.splitArray(tail, n)
      list.appendAll(tailList)
    }
    list.toList
  }
}